//
//  UserModel.m
//  ai2ban
//
//  Created by Heartbeats on 2018/1/21.
//  Copyright © 2018年 mac book pro. All rights reserved.
//

#import "UserModel.h"

@implementation AdressModel

- (NSString *)adressInfo {
    return [NSString stringWithFormat:@"%@%@%@%@", self.provinceName, self.cityName, self.districtName, self.addressName];
}

@end



@interface UserModel()


@end

@implementation UserModel

- (void)setAddresses:(NSMutableArray<AdressModel *> *)addresses {
    _addresses = addresses;
    [self getDefaultAddress];
}

-(AdressModel *)getDefaultAddress {
    if (self.defaultAdress) {
        return self.defaultAdress;
    }
    for (AdressModel *model in self.addresses) {
        if (model.isDefault) {
            self.defaultAdress = model;
            return self.defaultAdress;
        }
        if (self.addresses.count > 0) {
            self.defaultAdress = self.addresses[0];
            return self.defaultAdress;
        }
    }
    return nil;
}
@end
